# -*-coding: Utf-8 -*-
# @File : serializer .py
# author: Chimengmeng
# blog_url : https://www.cnblogs.com/dream-ze/
# Time：2024/7/1
from rest_framework import serializers
from apps.backend.models import User


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ["id", "username", "password", "phone", "mail", "real_name", "del_tag", "deletion_time", "create_time",
                  "update_time"]

        # 添加额外的 字段 参数限制条件
        extra_kwargs = {
            # 限制 id 字段只做读取
            'id': {'read_only': True},
            'password': {'write_only': True},
        }
